package com.imooc.controller;

import com.imooc.domain.Test;
import com.imooc.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Description:
 * Author: gzj
 * Date: 2024/11/8 10:43
 */
@RestController
@RequestMapping("test")
public class TestController {

    @Autowired
    private TestService service;


    @PostMapping("/insert")
    public String insert(@RequestBody Test test) {
        test.setDelFlag(0);
        service.insert(test);
        return "ok";
    }

    @PostMapping("/update")
    public String update(@RequestBody Test test) {
        service.update(test);
        return "ok";
    }

    @PostMapping("/delete")
    public String delete(@RequestBody Test test) {
        service.delete(test);
        return "ok";
    }

    @PostMapping("/list")
    public List<Test> list(@RequestBody Test test) {
        return service.list(test);
    }
}
